package com.bwie.filter;

import com.bwie.common.domain.User;
import com.bwie.mapper.SysUserMapper;
import com.google.common.hash.BloomFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @className: UserFilter
 * @Description: TODO
 * @version: v1.８.0
 * @author: 汪菲阳
 * @date: 2025/10/22 10:43
 */
@Component
public class UserFilter implements ApplicationRunner {
    @Autowired
    private BloomFilter<String> bloomFilter;
    @Autowired
    private SysUserMapper userMapper;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        //查询所有的用户手机号
        List<User> userList=userMapper.selectAllUser();
        //遍历集合
        for (User user : userList) {
            //获取手机号
            String userPhone = user.getUserPhone();
            //存入布隆过滤器中
            bloomFilter.put(userPhone);
        }
    }
}
